package com.appcenter.message.mapper;

import com.appcenter.message.input.dingconfig.GetDingConfigsInput;
import com.appcenter.message.model.DingConfigs;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
@Repository
public interface DingConfigsMapper extends Mapper<DingConfigs> {
    @Select("SELECT * FROM dingconfigs WHERE AppCode = #{AppCode}")
    DingConfigs getDingConfig(String AppCode);

    @Select("<script>" +
            "select * from dingconfigs where 1=1 " +
            "" +
            " <when test='keyword!=null'>" +
            " AND (AppCode like concat('%',#{keyword},'%') or AppName like concat('%',#{keyword},'%'))" +
            " </when>" +
            "" +
            " <when test='AppCode!=null'>" +
            " AND AppCode = #{AppCode}" +
            " </when>" +
            "" +
            "</script>")
    public List<DingConfigs> SearchDingConfigs(GetDingConfigsInput input);

}
